#include<iostream>
#include<string>
#include<regex>

int main(){
    std::string str = "GET /www.google.com/search?q=regex&limit=10 HTTP/1.1\r\n";
    std::regex e(
        "(GET|HEAD|POST|PUT|DELETE) ([^?]*)(?:\\?(.*))? (HTTP/1\\.[01])(?:\n|\r\n)?",
        std::regex::icase
    );
    std::smatch matches;
    std::regex_match(str, matches, e);
    int i = 0;
    for(auto &match : matches){
        std::cout << "match[" << i++ << "]";
        std::cout << match << std::endl;
    }
    return 0;
}

